Use case: SDIO configuration and card identification sequence ¶
The card identification function performs communication with the SDIO card and extracts the card’s key information, needed before applying the user configurations and starting operation. Users can provide a custom identification sequence to handle device-specific requirements or vendor extensions that differ from the default flow.
|
HAL1 |
HAL2 |
|---|---|
|
In HAL1 (Callback Registration): User used to register his custom card identification function using
|
In HAL2 (Direct Parameter): The sequence is changed, there is no registration step and the user should pass the identification function directly as the third argument to
|
Code Snippet
|
HAL1 |
HAL2 |
|---|---|
hsdio.Instance = SDMMC1;
hsdio.Init = user_sdio_config;
/* Register custom card identification function if needed */
#if defined(USER_SDIO_USE_CUSTOM_IDENTIFY)
/* Register custom card identification function */
HAL_SDIO_RegisterIdentifyCardCallback(&hsdio,
USER_SDIO_IdentifyCard);
#else
/* Do nothing; use default card identification */
#endif
/* Continue with SDIO initialization and configuration */
HAL_SDIO_Init(&hsdio);
HAL_StatusTypeDef USER_SDIO_IdentifyCard(SDIO_HandleTypeDef *hsdio)
{
/* Custom card identification sequence */
.
..
...
return HAL_OK;
}
|
/* Perform SDIO driver initialization */
HAL_SDIO_Init(&hsdio, HAL_SDIO_CARD_1);
/* Perform SDIO configuration */
#if defined(USER_SDIO_USE_CUSTOM_IDENTIFY)
/* Provide custom identify card function */
HAL_SDIO_SetConfig(&hsdio,
&user_sdio_config,
USER_SDIO_IdentifyCard);
#else
/* Pass NULL as third param; use default card identification */
HAL_SDIO_SetConfig(&hsdio, &user_sdio_config, NULL);
#endif
hal_status_t USER_SDIO_IdentifyCard(hal_sdio_handle_t *hsdio)
{
/* Custom card identification sequence */
.
..
...
return HAL_OK;
}
|